<?php

namespace App\Http\Resources\Admin\V1;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

class RoleResource extends JsonResource
{
    /**
     * @expalin 资源格式化
     * @param Request $request
     * @return array
     * @method
     * @author 陈文小超
     * @maxim from专注to执行
     * @time 2021/3/31/11:04
     */
    public function toArray($request)
    {
        return [
            'id'           => (int) $this->id,
            'name'         => (string) $this->name,
            'menus'        => $this->menus,
            'permissions'  => $this->permissions,
            'is_enable'    => (int) $this->is_enable,
            'is_super'     => (int) $this->is_super,
            'created_time' => (int) strtotime($this->created_time),
            'updated_time' => (int) strtotime($this->updated_time),
        ];
    }
}
